import {listEvent} from "@/api/forum/event"
import {defineStore} from 'pinia'

const useEventStore = defineStore(
  'event',
  {
    state: () => ({
        eventList:[],
        isLoadEvent: false,
    }),
    actions: {
        //初始化筛选
        getEventList(){
            this.isLoadEvent= true;
            var query = {
                pageNum : 1,
                pageSize : 15,
                state: 0,
                orderByColumn: "create_time",
                isAsc: "desc",
            }
            listEvent(query).then(res=>{
                this.eventList = res.rows;
                this.isLoadEvent= false;
            })
        },
        getEventListForSchoolId(schoolId){
            this.isLoadEvent= true;
            var query = {
                schoolId: schoolId,
                pageNum : 1,
                pageSize : 10,
                state: 0,
                orderByColumn: "create_time",
                isAsc: "desc",
            }
            listEvent(query).then(res=>{
                this.eventList = res.rows;
                this.isLoadEvent= false;
            })
        },
    }
  })


export default useEventStore